package ztc.servlet;

import ztc.common.StuBean;
import ztc.service.DBUsers;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by ztc on 16-4-17.下午8:45
 */
public class StuRegister extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        String id=request.getParameter("id");
        String name=request.getParameter("name");
        String sex=request.getParameter("sex");
        String classs=request.getParameter("class");
        String institute=request.getParameter("institute");
        String mac=request.getParameter("mac");
        StuBean stu=new StuBean(id,name,sex,classs,institute,mac);
        PrintWriter out=response.getWriter();
        if(new DBUsers().regStudent(stu))
            out.println("success");
        else
            out.println("failed");
        out.close();
    }
}
